Tiny Python Projects: Learn coding and testing with puzzles and games by Ken Youens-Clark

Tiny Python Projects: Learn coding and testing with puzzles and games by Ken Youens-Clark

Author:Ken Youens-Clark
Language: eng
Format: mobi, epub
Publisher: Manning Publications Co.
Published: 2020-08-07T22:00:00+00:00


12.3 Discussion

I like this problem because there are so many interesting ways to solve it. I know, I know, Python likes there to be “one obvious way” to solve it, but let’s explore, shall we? There’s nothing in get_args() that we haven’t seen several times by now, so let’s skip that.

12.3.1 Iterating through elements in a sequence

Assume that we have the following cruel message:

>>> text = '2 million dollars or the cat sleeps with the fishes!'

I want to randomly upper- and lowercase the letters. As suggested in the earlier description of the problem, we can use a for loop to iterate over each character. One way to print an uppercase version of the text is to print an uppercase version of each letter:

for char in text:

print(char.upper(), end='')



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(55937)
What's Done in Darkness by Kayla Perrin(26542)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19018)
The Fifty Shades Trilogy & Grey by E L James(18984)
Shot Through the Heart by Mercy Celeste(18892)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17010)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(16900)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16827)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16730)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16354)
The Subtle Art of Not Giving a F*ck by Mark Manson(14284)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14084)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13469)
Scorched Earth by Nick Kyme(12723)
Drei Generationen auf dem Jakobsweg by Stein Pia(10930)
Suna by Ziefle Pia(10856)
Scythe by Neal Shusterman(10290)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9489)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9332)
This is Going to Hurt by Adam Kay(9118)